/******************************************************************************************
 * Import
 ******************************************************************************************/

// module
import _ from 'lodash';
import Taro, { Component } from '@tarojs/taro'
import { View } from '@tarojs/components'

// project
import CompBase from '../_/base';

/******************************************************************************************
 * Export Class
 ******************************************************************************************/

export default class CAround extends CompBase {

    /**
     * 使用外部css样式
     */
    static options = {
        addGlobalClass: true
    }
    
	/**
     * 初始化
     */
    constructor(props) {
        super(props);

        // Base公用属性
        this.props.abs; this.props.rel;
        this.props.zindex; this.props.top; this.props.bottom; this.props.left; this.props.right;
        this.props.f; this.props.w; this.props.h; this.props.lh; this.props.bg; this.props.opacity;
        this.props.ma; this.props.mt; this.props.mb; this.props.ml; this.props.mr; this.props.mx; this.props.my;
        this.props.pa; this.props.pt; this.props.pb; this.props.pl; this.props.pr; this.props.px; this.props.py;
        this.props.ba; this.props.bt; this.props.bb; this.props.bl; this.props.br; this.props.bx; this.props.by;
        this.props.ra; this.props.rt; this.props.rb; this.props.rl; this.props.rr;
        this.props.color; this.props.size; this.props.bold; this.props.align;
        this.props.df; this.props.dn; this.props.db; this.props.di;
        this.props.oh; this.props.oa; this.props.os;
        this.props.x; this.props.y;
        
        // 本组件额外添加属性

        // 初始化props
        this.init(this.props);
	}
	
	/**
     * 固定样式
     */
    getFixedStyles() {
        return {
			flex: 1,
            flexDirection: 'row',
			justifyContent: 'space-around',
            alignItems: 'center'
        }
    }
    
    /**
     * click事件处理器
     */
    handleOnClick() {
        if (this.props.onClick && _.isFunction(this.props.onClick)) {
           this.props.onClick(...arguments);
       }
   }

   /**
    * langPress事件处理器
    */
   handleOnLangPress() {
       if (this.props.onLangPress && _.isFunction(this.props.onLangPress)) {
           this.props.onLangPress(...arguments);
       }
   }

	/**
	 * 渲染
	 */
	render() {

        // 计算touchClass
        let className = 'touch-default';
        if (this.props.touchClass) className = 'touch-' + this.props.touchClass;

        // 渲染
		return (
			<View className={className} style={this.styles} onClick={this.handleOnClick} onLongPress={this.handleOnLangPress}>
				{this.props.children}
			</View>
		);
	}
}
